package com.study.meng.bigevent.mapper;

import com.study.meng.bigevent.entity.User;
import org.apache.ibatis.annotations.*;

/**
 * @author 86150
 * @description 针对表【user】的数据库操作Mapper
 * @createDate 2025-06-17 10:23:07
 * @Entity com.study.meng.bigevent.entity.User
 */
@Mapper
public interface UserMapper {
    @Insert("insert into user (username, password,nickname,email, create_time, update_time) values (#{username}, #{password}, #{nickname},#{email},now(),now())")
    Integer insert(User user);

    @Select("select * from user where username = #{username}")
    User selectByUserName(String username);

    @Update("update user set username = #{username} , nickname = #{nickname}, email = #{email}, update_time = now() where id = #{id}")
    Integer updateById(User user);

    @Update("update user set user_pic = #{avatar}, update_time = now() where id = #{userId}")
    Integer updateAvatar(@Param("avatar") String avatar, @Param("userId") Integer userId);

    @Update("update user set password = #{password}, update_time = now() where id = #{id}")
    Integer updatePwd(User user);

    @Select("select * from user where id = #{userId}")
    User selectById(Integer userId);

    @Delete("delete from user where id = #{userId}")
    int deleteById(Integer userId);
}




